package org.xiyu.yee.onekeyminer_chainable_visual;

import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
// import net.neoforged.neoforge.event.server.ServerStartingEvent; // 移除服务端事件import
import org.slf4j.Logger;
import org.xiyu.yee.onekeyminer_chainable_visual.client.ClientRenderHandler;
import org.xiyu.yee.onekeyminer_chainable_visual.client.ModernConfigScreen;

import java.util.function.Supplier;

// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(Onekeyminer_chainable_visual.MODID)
public class Onekeyminer_chainable_visual {
    // Define mod id in a common place for everything to reference
    public static final String MODID = "onekeyminer_chainable_visual";
    // Directly reference a slf4j logger
    private static final Logger LOGGER = LogUtils.getLogger();
    // (scaffold examples removed) Keep DeferredRegister objects only if the mod will actually register content.
    public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
    public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);

    // The constructor for the mod class is the first code that is run when your mod is loaded.
    // FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
    public Onekeyminer_chainable_visual(IEventBus modEventBus, ModContainer modContainer) {
        // Register the commonSetup method for modloading
        modEventBus.addListener(this::commonSetup);

        // 客户端专用模组 - 不应该注册服务端事件总线！
        // Register ourselves for server and other game events we are interested in.
        // Note that this is necessary if and only if we want *this* class (Onekeyminer_chainable_visual) to respond directly to events.
        // Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
        // NeoForge.EVENT_BUS.register(this); // 移除 - 避免与主模组冲突

        // Register our mod's ModConfigSpec so that FML can create and load the config file for us
        modContainer.registerConfig(ModConfig.Type.CLIENT, Config.SPEC);
        
        // Register configuration screen factory
                // 配置屏幕可以通过模组配置菜单访问
        // 如果需要自定义配置屏幕，可以添加按键绑定来打开
    }

    private void commonSetup(final FMLCommonSetupEvent event) {
        // example scaffold logging removed; keep only necessary startup logs
    }

    // no creative tab additions by default

    // 移除服务端事件监听 - 客户端专用模组不应该处理服务端事件
    // You can use SubscribeEvent and let the Event Bus discover methods to call
    // @SubscribeEvent
    // public void onServerStarting(ServerStartingEvent event) {
    // }

    // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
    @EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
    public static class ClientModEvents {
        @SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event) {
        }
    }
}
